package com.javabi.htmlbuilder.css.unit;

import com.javabi.htmlbuilder.css.CSSBuilder;
import com.javabi.htmlbuilder.css.CSSDeclaration;

/**
 * A CSS Unit Declaration.
 */
public abstract class CSSUnitDeclaration implements CSSDeclaration {

	/** The number. */
	private final CSSUnitNumber number;

	/**
	 * Creates a new declaration.
	 * @param number the number.
	 */
	protected CSSUnitDeclaration(CSSUnitNumber number) {
		if (number == null) {
			throw new NullPointerException();
		}
		this.number = number;
	}

	/**
	 * Append this to the given css builder.
	 * @param css the css builder.
	 * @return the css builder.
	 */
	public CSSBuilder appendTo(CSSBuilder css) {
		css.property(getPropertyName());
		number.appendTo(css);
		return css;
	}

}
